package lily.phs.object;

import lily.phs.database.Constants;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;


public class LastPostnatalCheck implements Constants{
	
	private Context mContext;
	
	private int lapc_id=-1;
	private String lapc_date="";
//	private float lapc_body_temprature=-1f;
	private String lapc_ordinary_healthstatus="";
	private String lapc_ordinary_mentalstatus="";
	private int lapc_bloodpressure_high=-1;
	private int lapc_bloodpressure_low=-1;
	private int lapc_has_breast_abnormal=-1;
	private String lapc_breast_abnormal="";
	private int lapc_has_lochia_abnormal=-1;
	private String lapc_lochia_abnormal="";
	private int lapc_has_uterus_abnormal=-1;
	private String lapc_uterus_abnormal="";
	private int lapc_has_wound_abnormal=-1;
	private String lapc_wound_abnormal="";
	private String lapc_other_abnormal="";
	private int lapc_has_recovered=-1;
	private String lapc_remaining="";
	private String lapc_guide="";
	private String lapc_other_guide="";
	private int lapc_need_transfer=-1;
	private String lapc_transfer_reason="";
	private String lapc_transfer_hospital="";
	private String lapc_doctor="";
	
	public LastPostnatalCheck(Context context){
		this.mContext = context;
	}

	public int getLapc_id() {
		return lapc_id;
	}

	public void setLapc_id(int lapc_id) {
		this.lapc_id = lapc_id;
	}

	public String getLapc_date() {
		return lapc_date;
	}

	public void setLapc_date(String lapc_date) {
		this.lapc_date = lapc_date;
	}

	public String getLapc_ordinary_healthstatus() {
		return lapc_ordinary_healthstatus;
	}

	public void setLapc_ordinary_healthstatus(String lapc_ordinary_healthstatus) {
		this.lapc_ordinary_healthstatus = lapc_ordinary_healthstatus;
	}

	public String getLapc_ordinary_mentalstatus() {
		return lapc_ordinary_mentalstatus;
	}

	public void setLapc_ordinary_mentalstatus(String lapc_ordinary_mentalstatus) {
		this.lapc_ordinary_mentalstatus = lapc_ordinary_mentalstatus;
	}

	public int getLapc_bloodpressure_high() {
		return lapc_bloodpressure_high;
	}

	public void setLapc_bloodpressure_high(int lapc_bloodpressure_high) {
		this.lapc_bloodpressure_high = lapc_bloodpressure_high;
	}

	public int getLapc_bloodpressure_low() {
		return lapc_bloodpressure_low;
	}

	public void setLapc_bloodpressure_low(int lapc_bloodpressure_low) {
		this.lapc_bloodpressure_low = lapc_bloodpressure_low;
	}

	public int getLapc_has_breast_abnormal() {
		return lapc_has_breast_abnormal;
	}

	public void setLapc_has_breast_abnormal(int lapc_has_breast_abnormal) {
		this.lapc_has_breast_abnormal = lapc_has_breast_abnormal;
	}

	public String getLapc_breast_abnormal() {
		return lapc_breast_abnormal;
	}

	public void setLapc_breast_abnormal(String lapc_breast_abnormal) {
		this.lapc_breast_abnormal = lapc_breast_abnormal;
	}

	public int getLapc_has_lochia_abnormal() {
		return lapc_has_lochia_abnormal;
	}

	public void setLapc_has_lochia_abnormal(int lapc_has_lochia_abnormal) {
		this.lapc_has_lochia_abnormal = lapc_has_lochia_abnormal;
	}

	public String getLapc_lochia_abnormal() {
		return lapc_lochia_abnormal;
	}

	public void setLapc_lochia_abnormal(String lapc_lochia_abnormal) {
		this.lapc_lochia_abnormal = lapc_lochia_abnormal;
	}

	public int getLapc_has_uterus_abnormal() {
		return lapc_has_uterus_abnormal;
	}

	public void setLapc_has_uterus_abnormal(int lapc_has_uterus_abnormal) {
		this.lapc_has_uterus_abnormal = lapc_has_uterus_abnormal;
	}

	public String getLapc_uterus_abnormal() {
		return lapc_uterus_abnormal;
	}

	public void setLapc_uterus_abnormal(String lapc_uterus_abnormal) {
		this.lapc_uterus_abnormal = lapc_uterus_abnormal;
	}

	public int getLapc_has_wound_abnormal() {
		return lapc_has_wound_abnormal;
	}

	public void setLapc_has_wound_abnormal(int lapc_has_wound_abnormal) {
		this.lapc_has_wound_abnormal = lapc_has_wound_abnormal;
	}

	public String getLapc_wound_abnormal() {
		return lapc_wound_abnormal;
	}

	public void setLapc_wound_abnormal(String lapc_wound_abnormal) {
		this.lapc_wound_abnormal = lapc_wound_abnormal;
	}

	public String getLapc_other_abnormal() {
		return lapc_other_abnormal;
	}

	public void setLapc_other_abnormal(String lapc_other_abnormal) {
		this.lapc_other_abnormal = lapc_other_abnormal;
	}

	public int getLapc_has_recovered() {
		return lapc_has_recovered;
	}

	public void setLapc_has_recovered(int lapc_has_recovered) {
		this.lapc_has_recovered = lapc_has_recovered;
	}

	public String getLapc_remaining() {
		return lapc_remaining;
	}

	public void setLapc_remaining(String lapc_remaining) {
		this.lapc_remaining = lapc_remaining;
	}

	public String getLapc_guide() {
		return lapc_guide;
	}

	public void setLapc_guide(String lapc_guide) {
		this.lapc_guide = lapc_guide;
	}

	public String getLapc_other_guide() {
		return lapc_other_guide;
	}

	public void setLapc_other_guide(String lapc_other_guide) {
		this.lapc_other_guide = lapc_other_guide;
	}

	public int getLapc_need_transfer() {
		return lapc_need_transfer;
	}

	public void setLapc_need_transfer(int lapc_need_transfer) {
		this.lapc_need_transfer = lapc_need_transfer;
	}

	public String getLapc_transfer_reason() {
		return lapc_transfer_reason;
	}

	public void setLapc_transfer_reason(String lapc_transfer_reason) {
		this.lapc_transfer_reason = lapc_transfer_reason;
	}

	public String getLapc_transfer_hospital() {
		return lapc_transfer_hospital;
	}

	public void setLapc_transfer_hospital(String lapc_transfer_hospital) {
		this.lapc_transfer_hospital = lapc_transfer_hospital;
	}

	public String getLapc_doctor() {
		return lapc_doctor;
	}

	public void setLapc_doctor(String lapc_doctor) {
		this.lapc_doctor = lapc_doctor;
	}
	
	public void insertLastPostnatalCheck(){
//		int result = -1;
		ContentValues value = new ContentValues();
		value.put(LAPC_COLUMN1, this.getLapc_id());
		value.put(LAPC_COLUMN2, this.getLapc_date());
//		value.put(LAPC_COLUMN3, this.getLapc_body_temprature());
		value.put(LAPC_COLUMN4, this.getLapc_ordinary_healthstatus());
		value.put(LAPC_COLUMN5, this.getLapc_ordinary_mentalstatus());
		value.put(LAPC_COLUMN6, this.getLapc_bloodpressure_high());
		value.put(LAPC_COLUMN7, this.getLapc_bloodpressure_low());
		value.put(LAPC_COLUMN8, this.getLapc_has_breast_abnormal());
		value.put(LAPC_COLUMN9, this.getLapc_breast_abnormal());
		value.put(LAPC_COLUMN10, this.getLapc_has_lochia_abnormal());
		value.put(LAPC_COLUMN11, this.getLapc_lochia_abnormal());
		value.put(LAPC_COLUMN12, this.getLapc_has_uterus_abnormal());
		value.put(LAPC_COLUMN13, this.getLapc_uterus_abnormal());
		value.put(LAPC_COLUMN14, this.getLapc_has_wound_abnormal());
		value.put(LAPC_COLUMN15, this.getLapc_wound_abnormal());
		value.put(LAPC_COLUMN16, this.getLapc_other_abnormal());
		value.put(LAPC_COLUMN17, this.getLapc_has_recovered());
		value.put(LAPC_COLUMN18, this.getLapc_remaining());
		value.put(LAPC_COLUMN19, this.getLapc_guide());
		value.put(LAPC_COLUMN20, this.getLapc_other_guide());
		value.put(LAPC_COLUMN21, this.getLapc_need_transfer());
		value.put(LAPC_COLUMN22, this.getLapc_transfer_reason());
		value.put(LAPC_COLUMN23, this.getLapc_transfer_hospital());
		value.put(LAPC_COLUMN24, this.getLapc_doctor());
		
		mContext.getContentResolver().insert(CONTENT_URI_TB19, value);
//		return result;
		
	}
	
	public void selectLastPostnatalCheck(int id){
		String where = LAPC_COLUMN1 + "=" + id + " ";
		Cursor cursor = mContext.getContentResolver().query(CONTENT_URI_TB19, null, where, null, null);
		
		while(cursor.moveToNext()){
			this.lapc_id = cursor.getInt(cursor.getColumnIndex(LAPC_COLUMN1));
			this.lapc_date = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN2));
//			this.lapc_body_temprature = cursor.getFloat(cursor.getColumnIndex(LAPC_COLUMN3));
			this.lapc_ordinary_healthstatus = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN4));
			this.lapc_ordinary_mentalstatus = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN5));
			this.lapc_bloodpressure_high = cursor.getInt(cursor.getColumnIndex(LAPC_COLUMN6));
			this.lapc_bloodpressure_low = cursor.getInt(cursor.getColumnIndex(LAPC_COLUMN7));
			this.lapc_has_breast_abnormal = cursor.getInt(cursor.getColumnIndex(LAPC_COLUMN8));
			this.lapc_breast_abnormal = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN9));
			this.lapc_has_lochia_abnormal = cursor.getInt(cursor.getColumnIndex(LAPC_COLUMN10));
			this.lapc_lochia_abnormal = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN11));
			this.lapc_has_uterus_abnormal = cursor.getInt(cursor.getColumnIndex(LAPC_COLUMN12));
			this.lapc_uterus_abnormal = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN13));
			this.lapc_has_wound_abnormal = cursor.getInt(cursor.getColumnIndex(LAPC_COLUMN14));
			this.lapc_wound_abnormal = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN15));
			this.lapc_other_abnormal = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN16));
			this.lapc_has_recovered = cursor.getInt(cursor.getColumnIndex(LAPC_COLUMN17));
			this.lapc_remaining = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN18));
			this.lapc_guide = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN19));
			this.lapc_other_guide = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN20));
			this.lapc_need_transfer = cursor.getInt(cursor.getColumnIndex(LAPC_COLUMN21));
			this.lapc_transfer_reason = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN22));
			this.lapc_transfer_hospital = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN23));
			this.lapc_doctor = cursor.getString(cursor.getColumnIndex(LAPC_COLUMN24));
			
		}
		cursor.close();
	}
	
	public void updateLastPostnatalCheck(int id){
		ContentValues value = new ContentValues();
		value.put(LAPC_COLUMN1, this.getLapc_id());
		value.put(LAPC_COLUMN2, this.getLapc_date());
//		value.put(LAPC_COLUMN3, this.getLapc_body_temprature());
		value.put(LAPC_COLUMN4, this.getLapc_ordinary_healthstatus());
		value.put(LAPC_COLUMN5, this.getLapc_ordinary_mentalstatus());
		value.put(LAPC_COLUMN6, this.getLapc_bloodpressure_high());
		value.put(LAPC_COLUMN7, this.getLapc_bloodpressure_low());
		value.put(LAPC_COLUMN8, this.getLapc_has_breast_abnormal());
		value.put(LAPC_COLUMN9, this.getLapc_breast_abnormal());
		value.put(LAPC_COLUMN10, this.getLapc_has_lochia_abnormal());
		value.put(LAPC_COLUMN11, this.getLapc_lochia_abnormal());
		value.put(LAPC_COLUMN12, this.getLapc_has_uterus_abnormal());
		value.put(LAPC_COLUMN13, this.getLapc_uterus_abnormal());
		value.put(LAPC_COLUMN14, this.getLapc_has_wound_abnormal());
		value.put(LAPC_COLUMN15, this.getLapc_wound_abnormal());
		value.put(LAPC_COLUMN16, this.getLapc_other_abnormal());
		value.put(LAPC_COLUMN17, this.getLapc_has_recovered());
		value.put(LAPC_COLUMN18, this.getLapc_remaining());
		value.put(LAPC_COLUMN19, this.getLapc_guide());
		value.put(LAPC_COLUMN20, this.getLapc_other_guide());
		value.put(LAPC_COLUMN21, this.getLapc_need_transfer());
		value.put(LAPC_COLUMN22, this.getLapc_transfer_reason());
		value.put(LAPC_COLUMN23, this.getLapc_transfer_hospital());
		value.put(LAPC_COLUMN24, this.getLapc_doctor());
		
		String where = LAPC_COLUMN1 + "=" + id + "";
		mContext.getContentResolver().update(CONTENT_URI_TB19, value, where, null);
		
	}
	
	public void delectLastPostnatalCheck(int id){
		String where = LAPC_COLUMN1 + "=" + id + "";
		mContext.getContentResolver().delete(CONTENT_URI_TB19, where, null);
		
	}

}
